<%@language=vbscript%>
<%
	Session("bChucnang")=5
	Session("FormName")="F45"
%>
<!--#include file="..\CheckSession.inc"-->
<!--#include file="..\RootContent.inc"-->
<!--#include file=..\getFormName.inc-->
<!--#include file="..\jvfunction.inc"-->
<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Hoan thanh xu ly</title>
</head>
<%	
bComm=Request("bComm")
IDTotrinh=Request("IDTotrinh")
bNgayHTXL=Request("bNgayHTXL")
if bNgayHTXL="" then
	bNgayHTXL=Date()
end if
bKQXL=Request("bKQXL")
if bComm="okadd" then
	sSQL="Select * from HTXLToTrinh where IDtotrinh='"& IDTotrinh &"' and Madonvi='"& Session("bMaDonVi") &"'"
	Set RecTmp=server.CreateObject("ADODB.Recordset")
	RecTmp.CursorType=3
	RecTmp.CacheSize=5
	RecTmp.Open sSQL,Conn
	if RecTmp.RecordCount <= 0 then
		sSQl="Insert into HTXLtotrinh(IDtotrinh,NgayHTXL,Madonvi,KQXL) values ('" _
		& IDTotrinh _
		&"','" & SaveDate(bNgayHTXL) _
		&"','"& Session("bMaDonVi") _
		&"','"& bKQXL &"')"
	else
		sSQL="Update HTXLToTrinh set NgayHTXL='" & SaveDate(bNgayHTXL) &"',KQXL='" & bKQXL &"' WHERE IDtotrinh='" & IDTotrinh & _
		"' and Madonvi='" & Session("bMaDonVi") &"'"
	end if
	Conn.Execute sSQL
	RecTmp.Close
	Set RecTmp=nothing
end if
sSQL="Select * from HTXLtotrinh where IDtotrinh='"& IDTotrinh &"' and Madonvi='"& Session("bMaDonVi") &"'"
	Set Rec=server.CreateObject("ADODB.Recordset")
	Rec.CursorType=3
	Rec.CacheSize=5
	Rec.Open sSQL,Conn
	if Rec.RecordCount > 0 then
		bNgayHTXL=Rec("NgayHTXL")
		bKQXL=Rec("KQXL")
	end if
	Rec.Close
	Set Rec= nothing
%>	
<!--#include file="..\jvfunction.inc"-->
<script language=vbscript runat=server>
Function SaveDate(vDate)
	dim bvitri1
	dim bvitri2
   if vDate<>"" then
	   vDate=trim(cstr(vDate))
	   bvitri1=instr(1,vDate,"/")
	   bMonth=left(vDate,bvitri1-1)
	   bvitri2=instr(bvitri1+1,vDate,"/")
	   Dim Temp
	   Temp=right(vDate,len(vDate)-bvitri1)
	   bDay=left(Temp,bvitri2-bvitri1-1)
	   bYear=right(vDate,len(vDate)-bvitri2)
	   SaveDate=bDay+"/"+bMonth+"/"+bYear
   else
	   SaveDate=""
   end if
End Function
Function FormatDate(vDate)
   If vDate <> "" Then
		vM = Right("0" & Month(vDate), 2)
		vD = Right("0" & Day(vDate), 2)
		vY = Right("19" & Year(vDate), 4)
		FormatDate = vD & "/" & vM & "/" & vY
	Else
		FormatDate=""
   End If
End Function
Function ModiString(mess_s)
	message = Replace("" & mess_s,"'", "''")
	ModiString=message
End function
</script>	
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--
function SetFocus(){
	if (!Noidung.TxtNgayHTXL.disabled){
		Noidung.TxtNgayHTXL.focus();
	}
}
function CmdOK_onclick() {
if (KTNhap()){
	bNgayHTXL=Noidung.TxtNgayHTXL.value;
	bKQXL=Noidung.TxtKQXL.value;
	window.Noidung.target="right";
	window.Noidung.action="frmHTXLTotrinh.asp?IDTotrinh="+"<%=IDTotrinh%>"+"&bComm=okadd"+"&bNgayHTXL="+ bNgayHTXL +"&bKQXL="+bKQXL;
	window.Noidung.submit();
	}
}
function CmdExit_onclick(){
	window.Noidung.target="right";
	window.Noidung.action="frmdsTotrinh.asp";
	window.Noidung.submit();
}
function KTNhap(){
	if (Noidung.TxtNgayHTXL.value==""){
		alert ("Bạn cần nhập ngày hoàn thành !");
		Noidung.TxtNgayHTXL.focus();
		return false;
	}
	if (Noidung.TxtNgayHTXL.value!=""){
		if (!isDate(Noidung.TxtNgayHTXL.value)){
			alert ("Ngày hoàn thành không hợp lệ!");
			Noidung.TxtNgayHTXL.focus();
			return false;
		}
	}
	return true;
}

function TxtNgayHTXL_onkeyup(str){
var keycode
keycode=window.event.keyCode
	if (isEdit(keycode,str)){
		Noidung.TxtNgayHTXL.value=editdate(trim(str))
	}
}
//-->
</SCRIPT>
<body bgcolor=#F8F9D9 topmargin="0" leftmargin="0" style="font-family:Times New Roman" onload="SetFocus()">
<form name=Noidung method=post>
<table border="0" cellspacing="1" width="100%" bgcolor="#F8F9D9" style="font-size:12pt">
<tr>
    <td width="100%" colspan="2" bgcolor="#000080" align="center"><font color="#FFFFFF"><span style="font-size: 11pt"><b>HOÀN THÀNH XỬ LÝ</b></span></font></td>
</tr>
<tr><td width="100%" colspan=2></td></tr>
<tr>
	<td width="18%">&nbsp;Ngày hoàn thành</td>
	<td width="82%">
		<input type=text name=TxtNgayHTXL value="<%=FormatDate(bNgayHTXL)%>" maxLength=10 size=10 style="font-family: Arial; width:50%" LANGUAGE=javascript onkeyup="return TxtNgayHTXL_onkeyup(this.value)" tabindex=1></td>
</tr>
<tr>
    <td width="18%" valign=top>&nbsp;Kết quả xử lý</td>
	<td width="82%">
		<textarea name=TxtKQXL maxLength=500 style='font-family:Arial; width:100%' rows=5 cols=82 tabindex=2><%=bKQXL%></textarea></td>
</tr>
<tr>

</tr>
</table>
<table width="100%" border="0" Cellspacing="1" Cellpadding=1 style="font-size:13pt" bgcolor="#F8F9D9">
</tr>
	<td width="35%"></td>
	<td width="15%"><Button name="CmdOK" style="font-family:Arial;width: 100%"  LANGUAGE=javascript onclick="return CmdOK_onclick()" accesskey="G" tabindex=3><p><u>G</u>hi nhận</p></Button></td>
	<td width="15%"><Button name="CmdExit" style="font-family: Arial;width: 100%" LANGUAGE=javascript onclick="return CmdExit_onclick()" accesskey="Y" tabindex=4><p>Qua<u>y</u> lại</p></Button></td>
	<td width="35%"></td>
</tr>
</Table>
</form>
</body>
</html>
<%
	Conn.Close
	set Conn=nothing
%>